Add an is_empty method to types with a len one
authormcarton <cartonmartin+git@gmail.com>
Fri, 15 Jan 2016 14:51:26 +0000 (15:51 +0100)
committermcarton <cartonmartin+git@gmail.com>
Sat, 16 Jan 2016 11:42:56 +0000 (12:42 +0100)
Fix all Clippy’s len_without_is_empty warnings.

src/cargo/core/package.rs
src/cargo/core/source.rs
src/cargo/util/dependency_queue.rs

index 7de725ebb52b58eb203c07d3da03b81c15715778..45242b076c390014a86e2178f76d63cf44e77abe 100644 (file)
@@ -129,6 +129,10 @@ impl PackageSet {
         PackageSet { packages: packages.to_vec() }
     }
 
+    pub fn is_empty(&self) -> bool {
+        self.packages.is_empty()
+    }
+
     pub fn len(&self) -> usize {
         self.packages.len()
     }
index fc57652879bc2bc098f17f0ace1b6ef4af31807d..74446f0eb68eb3869056239d1fb7d5c262b2ada5 100644 (file)
@@ -419,6 +419,10 @@ impl<'src> SourceMap<'src> {
         self.map.insert(id.clone(), source);
     }
 
+    pub fn is_empty(&self) -> bool {
+        self.map.is_empty()
+    }
+
     pub fn len(&self) -> usize {
         self.map.len()
     }
index 499521bb3aedc8e7d9f5faa8cf2fe36cce3419ea..78d48232db4adf0b69c98dec120c233f5bd11ce5 100644 (file)
@@ -110,6 +110,11 @@ impl<K: Dependency, V> DependencyQueue<K, V> {
         Some((fresh, key, data))
     }
 
+    /// Returns whether there are remaining packages to be built.
+    pub fn is_empty(&self) -> bool {
+        self.dep_map.is_empty() && self.pending.is_empty()
+    }
+
     /// Returns the number of remaining packages to be built.
     pub fn len(&self) -> usize {
         self.dep_map.len() + self.pending.len()